﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using QzEbook.AccessObject;
using System.Collections.Generic;
using System.Text;
using QzEbook.View;

public partial class tag : System.Web.UI.Page
{
    StringBuilder sb;
    protected void Page_Load(object sender, EventArgs e)
    {
        BindSitemap();
        BindData();
    }

    private void BindSitemap()
    {
        WebMaster master = this.Master as WebMaster;
        string name = "所有标签";
        string path = Request.Url.PathAndQuery;
        QzSiteMapNode node = new QzSiteMapNode(path, name, name);
        master.sitemap.addChild(node);
    }

    private void BindData()
    {
        sb = new StringBuilder();
        sb.AppendLine("<table id=\"tagList\">");


        Control contentBody = this.Master.FindControl("ContenBody");

        Tag tag = new Tag();
        List<Tag> list=tag.selectList();
        int i = 0;
        foreach (Tag item in list)         
        {
            
            if (i == 0)
            {
                sb.AppendLine("<tr>");
            }
            sb.AppendFormat("<td>{0}</td>", Tag.getLinkHtml(item.Id,item.Count));
            i = ++i % 3;
            if (i == 0)
            {
                sb.AppendLine("</tr>");
            }
        }

        sb.AppendLine("</table>");

        Literal literal = new Literal();
        literal.Text = sb.ToString();

        contentBody.Controls.Add(literal);
    }
}
